home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Jan 12, 1998
- // Author: mgr
- //
- // Description:
- // The attachCurveMidPoint() procedure takes the selected two curves
- // (the end of curve1 and the start of curve2) and joins them at the
- // midpoint of the ends. If you don't want to attach the curves then
- // call this proc with $doAttach = 0.
- //
- // Input Arguments:
- // $doAttach - if 0 just move cvs, if 1 attach results
- //
- // Return Value:
- // String array.
- //
-
- global proc string[] attachCurveMidPoint( int $doAttach )
- {
- global int $gSelectNurbsCurvesBit;
- string $curvesList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit`;
-
- string $resultCurve[];
- int $numCurves = size($curvesList);
- if ( $numCurves < 2 )
- {
- error("Need to select two curves.");
- return $resultCurve;
- }
-
- // make copies of the two curves
- //
- $curvesList = `duplicate`;
-
- // get the last cv on the first curve and the first cv on the second curve
- //
- int $degree = eval("getAttr " + $curvesList[0] + ".degree");
- int $numSpans = eval("getAttr " + $curvesList[0] + ".spans");
- int $numCVs = $degree + $numSpans;
-
- int $lastCV = $numCVs - 1;
- float $cvCurve1[] = `getAttr ($curvesList[0] + ".cp[" + $lastCV + "]")`;
- float $cvCurve2[] = `getAttr ($curvesList[1] + ".cp[0]")`;
-
- // this is the vector between the two cvs
- //
- float $vector[3];
- $vector[0] = $cvCurve2[0] - $cvCurve1[0];
- $vector[1] = $cvCurve2[1] - $cvCurve1[1];
- $vector[2] = $cvCurve2[2] - $cvCurve1[2];
-
- // calculate the midpoint between the two cvs
- //
- float $cvNew[3];
- $cvNew[0] = $cvCurve1[0] + ($vector[0] * 0.5);
- $cvNew[1] = $cvCurve1[1] + ($vector[1] * 0.5);
- $cvNew[2] = $cvCurve1[2] + ($vector[2] * 0.5);
-
- // move the end cv of curve1 and the start cv of curve2 to the midpoint
- //
- eval("select -r " + $curvesList[0] + ".cv[" + $lastCV + "] " + $curvesList[1] + ".cv[0]");
- move -a $cvNew[0] $cvNew[1] $cvNew[2];
-
- // attach the 2 curves if required
- //
- if ( $doAttach == 1 )
- {
- // attach curve1 to curve2
- //
- string $attachedCurve[] = eval("attachCurve -ch 0 -rpo 1 -kmk 1 " + $curvesList[0] + " " + $curvesList[1]);
-
- // the second copied curve is no longer needed
- //
- delete $curvesList[1];
-
- $resultCurve[0] = $attachedCurve[0];
- }
- else
- {
- $resultCurve[0] = $curvesList[0];
- $resultCurve[1] = $curvesList[1];
- }
-
- select -r $resultCurve;
- return $resultCurve;
- }
-